<?php

/**
 * portfolio actions.
 *
 * @package    lezgro
 * @subpackage portfolio
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class sluggerActions extends sfActions
{
   public function executeGenerateFriendlyUri(sfWebRequest $request){
      $this->forward404Unless($request->isXmlHttpRequest(), sprintf('Error there no such uri'));
      $text=$request->getParameter('text');
      $table=$request->getParameter('table');
      $slug=UrlParser::slugify($text);
      if(!Doctrine::getTable($table)->findOneBy('slug',$slug))
          $response['slug']=$slug;
      else $response['errors']=array('Error'=>'Change uri manually, this alredy in use');
      return $this->renderText(json_encode($response));
  }
}
